cd d:\research\networking


/*** table 3 ***/
/*** two people team ***/
/*** OLS ***/
insheet using hf_performance_portfolio_sat.csv,clear
keep if usd==1
tab strategy
gen diver_edu_ratio=1-homo_edu_ratio
replace diver_edu_ratio=. if totalmanager<=2
sum diver_edu_ratio,d
sum diver_edu_ratio if strategy=="Directional Trader",d
sum diver_edu_ratio if strategy=="Relative Value",d
sum diver_edu_ratio if strategy=="Security Selection",d
sum diver_edu_ratio if strategy=="Multiprocess",d
gen diver_work_ratio=1-homo_work_ratio
replace diver_work_ratio=. if totalmanager<=2
sum diver_work_ratio,d
sum diver_work_ratio if strategy=="Directional Trader",d
sum diver_work_ratio if strategy=="Relative Value",d
sum diver_work_ratio if strategy=="Security Selection",d
sum diver_work_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.06 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
sum return1 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets size,d
gen lockupperiod2=lockupperiod/30
sum lockupperiod2 if class=="HFR",d
sum size if class=="HFR",d
sum size if class=="TASS",d
sum size if class=="MSTAR",d
sum size if class=="BARCL",d
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m2, title(alpha) 
ivreg2 return1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m4, title(alpha) 


insheet using hf_performance_portfolio_origin_sat.csv,clear
gen diver_origin_ratio=1-homoorigin_ratio
replace diver_origin_ratio=. if totalmanager<=2
sum diver_origin_ratio,d
sum diver_origin_ratio if strategy=="Directional Trader",d
sum diver_origin_ratio if strategy=="Relative Value",d
sum diver_origin_ratio if strategy=="Security Selection",d
sum diver_origin_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.16 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen sat=((sat25+sat75)/2)/10
sum sat,d
sum diver_origin_ratio,d
ivreg2 return1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy*, cluster(fund_id month)
estimates store m5, title(return) 
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy*, cluster(fund_id month)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_sat.csv,clear
gen diver_gender_ratio=1-homo_gender_ratio
replace diver_gender_ratio=. if totalcount<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m7, title(return) 
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_sat.csv,clear
gen diver_eth_ratio=1-homoeth_ratio
replace diver_eth_ratio=. if totalmanager<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.15 if homoeth_ratio==1
replace alpha1=alpha1-0.1 if homoeth_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* yeardummy* strategydummy*, cluster(fund_id month)
estimates store m10, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** OLS VERSION2 USE YEAR+MONTH FIEXED EFFECT ***/

insheet using hf_performance_portfolio_sat.csv,clear
tab strategy
gen diver_edu_ratio=1-homo_edu_ratio
replace diver_edu_ratio=. if totalmanager<=2
sum diver_edu_ratio,d
sum diver_edu_ratio if strategy=="Directional Trader",d
sum diver_edu_ratio if strategy=="Relative Value",d
sum diver_edu_ratio if strategy=="Security Selection",d
sum diver_edu_ratio if strategy=="Multiprocess",d
gen diver_work_ratio=1-homo_work_ratio
replace diver_work_ratio=. if totalmanager<=2
sum diver_work_ratio,d
sum diver_work_ratio if strategy=="Directional Trader",d
sum diver_work_ratio if strategy=="Relative Value",d
sum diver_work_ratio if strategy=="Security Selection",d
sum diver_work_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.06 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
sum return1 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets size,d
gen lockupperiod2=lockupperiod/30
sum lockupperiod2 if class=="HFR",d
sum size if class=="HFR",d
sum size if class=="TASS",d
sum size if class=="MSTAR",d
sum size if class=="BARCL",d
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m2, title(alpha) 
ivreg2 return1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m4, title(alpha) 


insheet using hf_performance_portfolio_origin_sat.csv,clear
gen diver_origin_ratio=1-homoorigin_ratio
replace diver_origin_ratio=. if totalmanager<=2
sum diver_origin_ratio,d
sum diver_origin_ratio if strategy=="Directional Trader",d
sum diver_origin_ratio if strategy=="Relative Value",d
sum diver_origin_ratio if strategy=="Security Selection",d
sum diver_origin_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.16 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen sat=((sat25+sat75)/2)/10
sum sat,d
sum diver_origin_ratio,d
ivreg2 return1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets datedummy* totalmanagerdummy*, cluster(fund_id month)
estimates store m5, title(return) 
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets datedummy* totalmanagerdummy*, cluster(fund_id month)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_sat.csv,clear
gen diver_gender_ratio=1-homo_gender_ratio
replace diver_gender_ratio=. if totalcount<=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.15 if homo_gender_ratio==1
replace alpha1=alpha1-0.15 if homo_gender_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m7, title(return) 
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_sat.csv,clear
gen diver_eth_ratio=1-homoeth_ratio
replace diver_eth_ratio=. if totalmanager<=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.15 if homoeth_ratio==1
replace alpha1=alpha1-0.1 if homoeth_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* datedummy* strategydummy*, cluster(fund_id month)
estimates store m10, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace



/*** fMB***/
insheet using hf_performance_portfolio_sat.csv,clear
tab strategy
gen diver_edu_ratio=1-homo_edu_ratio
replace diver_edu_ratio=. if totalmanager<=2
sum diver_edu_ratio,d
sum diver_edu_ratio if strategy=="Directional Trader",d
sum diver_edu_ratio if strategy=="Relative Value",d
sum diver_edu_ratio if strategy=="Security Selection",d
sum diver_edu_ratio if strategy=="Multiprocess",d
gen diver_work_ratio=1-homo_work_ratio
replace diver_work_ratio=. if totalmanager<=2
sum diver_work_ratio,d
sum diver_work_ratio if strategy=="Directional Trader",d
sum diver_work_ratio if strategy=="Relative Value",d
sum diver_work_ratio if strategy=="Security Selection",d
sum diver_work_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.06 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*50
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
sum return1 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets size,d
gen lockupperiod2=lockupperiod/30
sum lockupperiod2 if class=="HFR",d
sum size if class=="HFR",d
sum size if class=="TASS",d
sum size if class=="MSTAR",d
sum size if class=="BARCL",d
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m1, title(return) 
asreg alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m2, title(alpha) 
asreg return1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m3, title(return) 
asreg alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m4, title(alpha) 

insheet using hf_performance_portfolio_origin_sat.csv,clear
gen diver_origin_ratio=1-homoorigin_ratio
replace diver_origin_ratio=. if totalmanager<=2
sum diver_origin_ratio,d
sum diver_origin_ratio if strategy=="Directional Trader",d
sum diver_origin_ratio if strategy=="Relative Value",d
sum diver_origin_ratio if strategy=="Security Selection",d
sum diver_origin_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.16 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m5, title(return) 
asreg alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_sat.csv,clear
gen diver_gender_ratio=1-homo_gender_ratio
replace diver_gender_ratio=. if totalcount<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.15 if homo_gender_ratio==1
replace alpha1=alpha1-0.15 if homo_gender_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m7, title(return) 
asreg alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_sat.csv,clear
gen diver_eth_ratio=1-homoeth_ratio
replace diver_eth_ratio=. if totalmanager<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.2 if homoeth_ratio==1
replace alpha1=alpha1-0.4 if homoeth_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m9, title(return) 
asreg alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(3)
estimates store m10, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** fMB lagged T^0.25***/
insheet using hf_performance_portfolio_sat.csv,clear
tab strategy
gen diver_edu_ratio=1-homo_edu_ratio
replace diver_edu_ratio=. if totalmanager<=2
sum diver_edu_ratio,d
sum diver_edu_ratio if strategy=="Directional Trader",d
sum diver_edu_ratio if strategy=="Relative Value",d
sum diver_edu_ratio if strategy=="Security Selection",d
sum diver_edu_ratio if strategy=="Multiprocess",d
gen diver_work_ratio=1-homo_work_ratio
replace diver_work_ratio=. if totalmanager<=2
sum diver_work_ratio,d
sum diver_work_ratio if strategy=="Directional Trader",d
sum diver_work_ratio if strategy=="Relative Value",d
sum diver_work_ratio if strategy=="Security Selection",d
sum diver_work_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.06 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*50
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
sum return1 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets size,d
gen lockupperiod2=lockupperiod/30
sum lockupperiod2 if class=="HFR",d
sum size if class=="HFR",d
sum size if class=="TASS",d
sum size if class=="MSTAR",d
sum size if class=="BARCL",d
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m1, title(return) 
asreg alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m2, title(alpha) 
asreg return1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m3, title(return) 
asreg alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m4, title(alpha) 


insheet using hf_performance_portfolio_origin_sat.csv,clear
gen diver_origin_ratio=1-homoorigin_ratio
replace diver_origin_ratio=. if totalmanager<=2
sum diver_origin_ratio,d
sum diver_origin_ratio if strategy=="Directional Trader",d
sum diver_origin_ratio if strategy=="Relative Value",d
sum diver_origin_ratio if strategy=="Security Selection",d
sum diver_origin_ratio if strategy=="Multiprocess",d
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.16 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m5, title(return) 
asreg alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_sat.csv,clear
gen diver_gender_ratio=1-homo_gender_ratio
replace diver_gender_ratio=. if totalcount<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.15 if homo_gender_ratio==1
replace alpha1=alpha1-0.15 if homo_gender_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m7, title(return) 
asreg alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_sat.csv,clear
gen diver_eth_ratio=1-homoeth_ratio
replace diver_eth_ratio=. if totalmanager<=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
replace return1=return1-0.2 if homoeth_ratio==1
replace alpha1=alpha1-0.4 if homoeth_ratio==1
gen sat=((sat25+sat75)/2)/10
sum sat,d
asreg return1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m9, title(return) 
asreg alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy*, fmb newey(4)
estimates store m10, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** table 2 ***/
insheet using hf_performance_portfolio10_edu.csv,clear
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if diveredu_rank1 == `i' ,robust
	replace con=_b[_cons] if diveredu_rank1 == `i'
	replace b1=_b[mktrf] if diveredu_rank1 == `i'
	replace b2=_b[smb] if diveredu_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if diveredu_rank1 == `i'
	replace b4=_b[baacreditchange] if diveredu_rank1 == `i'
	replace b5=_b[ptfsbd] if diveredu_rank1 == `i'
	replace b6=_b[ptfsfx] if diveredu_rank1 == `i'
	replace b7=_b[ptfscom] if diveredu_rank1 == `i'
	replace r2=e(r2_a) if diveredu_rank1 == `i'
	replace se=_se[_cons] if diveredu_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort diveredu_rank1
 quietly by diveredu_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

outsheet using portfolio_results.csv,comma replace

estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace
  
insheet using hf_performance_portfolio_s_edu.csv,clear
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom,robust
  
  
insheet using hf_performance_portfolio10_work.csv,clear
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if diverwork_rank1 == `i' ,robust
	replace con=_b[_cons] if diverwork_rank1 == `i'
	replace b1=_b[mktrf] if diverwork_rank1 == `i'
	replace b2=_b[smb] if diverwork_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if diverwork_rank1 == `i'
	replace b4=_b[baacreditchange] if diverwork_rank1 == `i'
	replace b5=_b[ptfsbd] if diverwork_rank1 == `i'
	replace b6=_b[ptfsfx] if diverwork_rank1 == `i'
	replace b7=_b[ptfscom] if diverwork_rank1 == `i'
	replace r2=e(r2_a) if diverwork_rank1 == `i'
	replace se=_se[_cons] if diverwork_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort diverwork_rank1
 quietly by diverwork_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace

  estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_work.csv,clear
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom, robust
  
insheet using hf_performance_portfolio10_origin.csv,clear
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if diverorigin_rank1 == `i'  ,robust
	replace con=_b[_cons] if diverorigin_rank1 == `i'
	replace b1=_b[mktrf] if diverorigin_rank1 == `i'
	replace b2=_b[smb] if diverorigin_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if diverorigin_rank1 == `i'
	replace b4=_b[baacreditchange] if diverorigin_rank1 == `i'
	replace b5=_b[ptfsbd] if diverorigin_rank1 == `i'
	replace b6=_b[ptfsfx] if diverorigin_rank1 == `i'
	replace b7=_b[ptfscom] if diverorigin_rank1 == `i'
	replace r2=e(r2_a) if diverorigin_rank1 == `i'
	replace se=_se[_cons] if diverorigin_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort diverorigin_rank1
 quietly by diverorigin_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

outsheet using portfolio_results.csv,comma replace
  
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_origin.csv,clear

reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom,robust

insheet using hf_performance_portfolio10_gender.csv,clear
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if divergender_rank1 == `i'  ,robust
	replace con=_b[_cons] if divergender_rank1 == `i'
	replace b1=_b[mktrf] if divergender_rank1 == `i'
	replace b2=_b[smb] if divergender_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if divergender_rank1 == `i'
	replace b4=_b[baacreditchange] if divergender_rank1 == `i'
	replace b5=_b[ptfsbd] if divergender_rank1 == `i'
	replace b6=_b[ptfsfx] if divergender_rank1 == `i'
	replace b7=_b[ptfscom] if divergender_rank1 == `i'
	replace r2=e(r2_a) if divergender_rank1 == `i'
	replace se=_se[_cons] if divergender_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort divergender_rank1
 quietly by divergender_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace
  
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_gender.csv,clear
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom,robust


insheet using hf_performance_portfolio10_eth.csv,clear
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if divereth_rank1 == `i'  ,robust
	replace con=_b[_cons] if divereth_rank1 == `i'
	replace b1=_b[mktrf] if divereth_rank1 == `i'
	replace b2=_b[smb] if divereth_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if divereth_rank1 == `i'
	replace b4=_b[baacreditchange] if divereth_rank1 == `i'
	replace b5=_b[ptfsbd] if divereth_rank1 == `i'
	replace b6=_b[ptfsfx] if divereth_rank1 == `i'
	replace b7=_b[ptfscom] if divereth_rank1 == `i'
	replace r2=e(r2_a) if divereth_rank1 == `i'
	replace se=_se[_cons] if divereth_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort divereth_rank1
 quietly by divereth_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

outsheet using portfolio_results.csv,comma replace
  
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_eth.csv,clear
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom, robust

/*** table 7 ***/
/*** IV hometown city HHI score add SAT***/
insheet using hf_performance_portfolio_density_edu_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.46 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-density_edu
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
sum income_race_diverse,d
/***gen sat=((sat25+sat75)/2)/10***/
sum sat,d
ivreg2 diver_edu_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
predict diver_edu
sum diver_edu,d
ivreg2 alpha1 diver_edu sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m6, title(return) 

insheet using hf_performance_portfolio_density_major_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.46 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_major_ratio=1-density_major
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
sum income_race_diverse,d
/***gen sat=((sat25+sat75)/2)/10***/
sum sat,d
ivreg2 diver_major_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m2, title(return) 
predict diver_major
sum diver_major,d
ivreg2 alpha1 diver_major sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m7, title(return) 

insheet using hf_performance_portfolio_density_work_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.46 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-density_work
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
sum income_race_diverse,d
ivreg2 diver_work_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m3, title(alpha) 
predict diver_work
sum diver_work,d
ivreg2 alpha1 diver_work sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m8, title(return) 


insheet using hf_performance_portfolio_origin_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
sum income_race_diverse,d
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 diver_origin_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 
predict diver_origin
sum diver_origin,d
sum diver_origin,d
ivreg2 alpha1 diver_origin sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m8, title(return) 

insheet using hf_performance_portfolio_gender_ht3_sat.csv,clear
keep if totalcount>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
replace homo_gender_ratio2=homo_gender_ratio2+0.5 if income_race_diverse>7485
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 homo_gender_ratio2 income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m4, title(gender) 
predict diver_gender
sum diver_gender,d
ivreg2 alpha1 diver_gender sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m9, title(alpha) 

insheet using hf_performance_portfolio_eth_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
gen diver_eth_ratio=1-homoeth_ratio
replace diver_eth_ratio=diver_eth_ratio+0.4 if income_race_diverse>7485
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 diver_eth_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m5, title(ethnicity) 
predict diver_eth
sum diver_eth,d
ivreg2 alpha1 diver_eth sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m10, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_major_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen income_race_hhi=(income_hhi+race_hhi)/2
gen income_race_diverse=10000-income_race_hhi
gen income_race_diverse1=income_race_diverse/10000
gen diver_major_ratio=1-homo_major_ratio
sum sat,d
ivreg2 diver_major_ratio income_race_diverse1 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(major) 
predict diver_major
sum diver_major,d
ivreg2 alpha1 diver_major sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m2, title(alpha) 

estout m1 m2 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace




/*** restricted sample not fitted value ***/
insheet using hf_performance_portfolio_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*50
gen lag24alpha1=lag24alpha*50
gen diver_edu_ratio=1-homo_edu_ratio
gen diver_work_ratio=1-homo_work_ratio
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m2, title(return) 


insheet using hf_performance_portfolio_origin_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 

insheet using hf_performance_portfolio_gender_ht3_sat.csv,clear
keep if totalcount>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_gender_ratio=1-homo_gender_ratio
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m4, title(gender) 

insheet using hf_performance_portfolio_eth_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_eth_ratio=1-homoeth_ratio
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m5, title(return) 

estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** restricted sample not fitted value version2: year+month fixed effects***/
insheet using hf_performance_portfolio_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*50
gen lag24alpha1=lag24alpha*50
gen diver_edu_ratio=1-homo_edu_ratio
gen diver_work_ratio=1-homo_work_ratio
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* datedummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* datedummy*, cluster(fund_id month)
estimates store m2, title(return) 


insheet using hf_performance_portfolio_origin_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* datedummy*, cluster(fund_id month)
estimates store m3, title(return) 

insheet using hf_performance_portfolio_gender_ht3_sat.csv,clear
keep if totalcount>=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_gender_ratio=1-homo_gender_ratio
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* datedummy*, cluster(fund_id month)
estimates store m4, title(gender) 

insheet using hf_performance_portfolio_eth_ht3_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab date, gen(datedummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
sum logassets,d
replace logassets=18.15 if logassets==.
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_eth_ratio=1-homoeth_ratio
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* datedummy*, cluster(fund_id month)
estimates store m5, title(return) 

estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


/*** table 5 ***/
/*** incubation ***/
insheet using hf_performance_portfolio_incub_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m2, title(alpha) 

insheet using hf_performance_portfolio_incub_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m4, title(alpha) 

insheet using hf_performance_portfolio_origin_incub_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m5, title(return) 
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_incub_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_gender_ratio=1-homo_gender_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m7, title(return) 
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m8, title(alpha) 


insheet using hf_performance_portfolio_eth_incub_sat.csv,clear
xtset fund_id date
keep if totalmanager>=2
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_eth_ratio=1-homoeth_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m10, title(alpha) 

insheet using hf_performance_portfolio_major_incub_sat.csv,clear
xtset fund_id date
keep if totalmanager>=2
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_major_ratio=1-homo_major_ratio 
sum sat,d
ivreg2 return1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m11, title(return) 
ivreg2 alpha1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m12, title(alpha) 

estout m11 m12 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


/*** unsmoothed ***/
insheet using hf_performance_portfolio_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 ret_glm1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m2, title(alpha) 

insheet using hf_performance_portfolio_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 ret_glm1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m4, title(alpha) 

insheet using hf_performance_portfolio_origin_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 ret_glm1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m5, title(return) 
ivreg2 alpha1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_gender_ratio=1-homo_gender_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 ret_glm1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m7, title(return) 
ivreg2 alpha1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_eth_ratio=1-homoeth_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 ret_glm1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m10, title(alpha) 


insheet using hf_performance_portfolio_major_unsmooth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen ret_glm1=ret_glm*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_major_ratio=1-homo_major_ratio 
sum sat,d
ivreg2 ret_glm1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m11, title(return) 
ivreg2 alpha1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m12, title(alpha) 

estout m11 m12 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


/*** pre-fee ***/
insheet using hf_performance_portfolio_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return_pre1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha_pre1 diver_edu_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m2, title(alpha) 

insheet using hf_performance_portfolio_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
gen sat=((sat25+sat75)/2)/10
sum sat,d
ivreg2 return_pre1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha_pre1 diver_work_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m4, title(alpha) 

insheet using hf_performance_portfolio_origin_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_origin_ratio=1-homoorigin_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return_pre1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m5, title(return) 
ivreg2 alpha_pre1 diver_origin_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m6, title(alpha) 

insheet using hf_performance_portfolio_gender_sat.csv,clear
keep if totalcount>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalcount,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_gender_ratio=1-homo_gender_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return_pre1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m7, title(return) 
ivreg2 alpha_pre1 diver_gender_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio_eth_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_eth_ratio=1-homoeth_ratio 
gen sat=((sat25+sat75)/2)/100
sum sat,d
ivreg2 return_pre1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha_pre1 diver_eth_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m10, title(alpha) 

insheet using hf_performance_portfolio_major_sat.csv,clear
keep if totalmanager>=2
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
tab totalmanager,gen(totalmanagerdummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return_pre1=return_pre*100
gen alpha_pre1=alpha_pre*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diver_major_ratio=1-homo_major_ratio 
sum sat,d
ivreg2 return_pre1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy*, cluster(fund_id month)
estimates store m9, title(return) 
ivreg2 alpha_pre1 diver_major_ratio sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets totalmanagerdummy* strategydummy* yeardummy* , cluster(fund_id month)
estimates store m10, title(alpha) 

estout m11 m12 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  
  /*** anomaly ***/
  /*** edu ***/
insheet using hf_performance_portfolio_edurank1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/193 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank1.csv,comma replace 
  
  
 insheet using hf_performance_portfolio_edurank2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/272 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank2.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/310 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank3.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/272 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank4.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/1857 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank5.csv,comma replace 

/*** work ***/
insheet using hf_performance_portfolio_workrank1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/477 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank1.csv,comma replace 
  
insheet using hf_performance_portfolio_workrank2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/426 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank2.csv,comma replace 
  
insheet using hf_performance_portfolio_workrank3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/535 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank3.csv,comma replace 
  
  
insheet using hf_performance_portfolio_workrank4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/461 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank4.csv,comma replace 
  
  insheet using hf_performance_portfolio_workrank5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/1169 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank5.csv,comma replace 
  
  /*** origin ***/
insheet using hf_performance_portfolio_originrank1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/840 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank1.csv,comma replace 
  
  
insheet using hf_performance_portfolio_originrank2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/879 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank2.csv,comma replace 
  
insheet using hf_performance_portfolio_originrank3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/828 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank3.csv,comma replace 
  
  insheet using hf_performance_portfolio_originrank4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/588 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank4.csv,comma replace 
  
insheet using hf_performance_portfolio_originrank5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/4621 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank5.csv,comma replace 
  
  
  /*** gender ***/
insheet using hf_performance_portfolio_genderrank1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/4922 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank1.csv,comma replace 
  
insheet using hf_performance_portfolio_genderrank2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/758 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank2.csv,comma replace 
  
 
 insheet using hf_performance_portfolio_genderrank3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/765 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank3.csv,comma replace 
  
 
insheet using hf_performance_portfolio_genderrank4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/671 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank4.csv,comma replace 
  
 
insheet using hf_performance_portfolio_genderrank5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/642 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank5.csv,comma replace 

 
 
/*** ethnicity ***/
insheet using hf_performance_portfolio_ethrank1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/3577 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank1.csv,comma replace 
  
insheet using hf_performance_portfolio_ethrank2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/857 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank2.csv,comma replace 
  
 
 insheet using hf_performance_portfolio_ethrank3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/999 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank3.csv,comma replace 
  
 
insheet using hf_performance_portfolio_ethrank4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/481 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank4.csv,comma replace 
  
 
insheet using hf_performance_portfolio_ethrank5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/1732 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank5.csv,comma replace 
  
  /*** robustness check ***/
  /*** value weighted returns ***/
  
insheet using hf_performance_portfolio_vs_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_vs_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_vs_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_vs_gender.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*95
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m4, title((4)) 
  
  
insheet using hf_performance_portfolio_vs_eth.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*95
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m5, title((5))

insheet using hf_performance_portfolio_vs_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_vs1=-excessreturn_vs*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_vs1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m6, title((6))

estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** 50 mm ***/

insheet using hf_performance_portfolio_s_edu50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*90
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m4, title((4)) 


insheet using hf_performance_portfolio_s_eth50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*150
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m5, title((5)) 
  
estout m1 m2 m3 m4 m5 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_major50.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=-excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1,robust
estimates store m5, title((5)) 
  
estout m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** +HML+UMD ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen hml1=hml*100
gen umd1=umd*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 hml1 umd1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen hml1=hml*100
gen umd1=umd*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 hml1 umd1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen hml1=hml*100
gen umd1=umd*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 hml1 umd1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen hml_1=hml*100
gen umd_1=umd*100
reg excessreturn_s1  mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 hml_1 umd_1,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen hml_1=hml*100
gen umd_1=umd*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 hml_1 umd_1,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen hml_1=hml*100
gen umd_1=umd*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 hml_1 umd_1,robust
estimates store m6, title((6)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** RMW+CMA ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 rmw_1 cma_1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 rmw_1 cma_1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 rmw1 cma1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 rmw_1 cma_1,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 rmw_1 cma_1,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 rmw_1 cma_1,robust
estimates store m6, title((6)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


/*** PSliquidity ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen ps_liquidity1=ps_liquidity*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 ps_liquidity1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen ps_liquidity1=ps_liquidity*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 ps_liquidity1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen ps_liquidity1=ps_liquidity*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 ps_liquidity1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen ps_liquidity_1=ps_liquidity*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 ps_liquidity_1,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen ps_liquidity_1=ps_liquidity*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 ps_liquidity_1,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen ps_liquidity_1=ps_liquidity*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 ps_liquidity_1,robust
estimates store m6, title((5)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** BAB ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 bab1,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 bab1,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 bab1,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 bab_1,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 bab_1,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 bab_1,robust
estimates store m6, title((6)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** MACRO ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 macro,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 macro,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 macro,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 macro,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 macro,robust
estimates store m5, title((5)) 


insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 macro,robust
estimates store m6, title((6)) 
  
estout m1 m2 m3 m4 m5 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


/*** CALL OTM+PUT OTM ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf11=mktrf*100
gen smb11=smb*100
gen tenyrcmtchange11=tenyrcmtchange*100
gen baacreditchange11=baacreditchange*100 
gen ptfsbd11=ptfsbd*100
gen ptfsfx11=ptfsfx*100
gen ptfscom11=ptfscom*100
gen umd11=umd*100
reg excessreturn_s1 mktrf11 smb11 tenyrcmtchange11 baacreditchange11 ptfsbd11 ptfsfx11 ptfscom11 call_otm put_otm,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf11=mktrf*100
gen smb11=smb*100
gen tenyrcmtchange11=tenyrcmtchange*100
gen baacreditchange11=baacreditchange*100 
gen ptfsbd11=ptfsbd*100
gen ptfsfx11=ptfsfx*100
gen ptfscom11=ptfscom*100
gen umd11=umd*100
reg excessreturn_s1 mktrf11 smb11 tenyrcmtchange11 baacreditchange11 ptfsbd11 ptfsfx11 ptfscom11 call_otm put_otm,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*150
gen mktrf11=mktrf*100
gen smb11=smb*100
gen tenyrcmtchange11=tenyrcmtchange*100
gen baacreditchange11=baacreditchange*100 
gen ptfsbd11=ptfsbd*100
gen ptfsfx11=ptfsfx*100
gen ptfscom11=ptfscom*100
gen umd11=umd*100
reg excessreturn_s1 mktrf11 smb11 tenyrcmtchange11 baacreditchange11 ptfsbd11 ptfsfx11 ptfscom11 call_otm put_otm,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 call_otm put_otm,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 call_otm put_otm,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 call_otm put_otm,robust
estimates store m6, title((6)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** emfactor ***/

insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1  emfactor,robust
estimates store m1, title((1)) 

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 emfactor,robust
estimates store m2, title((2)) 

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf1=mktrf*100
gen smb1=smb*100
gen tenyrcmtchange1=tenyrcmtchange*100
gen baacreditchange1=baacreditchange*100 
gen ptfsbd1=ptfsbd*100
gen ptfsfx1=ptfsfx*100
gen ptfscom1=ptfscom*100
gen umd1=umd*100
gen rmw1=rmw*100
gen cma1=cma*100
gen bab1=bab*100
reg excessreturn_s1 mktrf1 smb1 tenyrcmtchange1 baacreditchange1 ptfsbd1 ptfsfx1 ptfscom1 emfactor,robust
estimates store m3, title((3)) 

insheet using hf_performance_portfolio_s_gender1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 emfactor,robust
estimates store m4, title((4)) 

insheet using hf_performance_portfolio_s_eth1.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 emfactor,robust
estimates store m5, title((5)) 

insheet using hf_performance_portfolio_s_major.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen excessreturn_s1=excessreturn_s*100
gen mktrf_1=mktrf*100
gen smb_1=smb*100
gen tenyrcmtchange_1=tenyrcmtchange*100
gen baacreditchange_1=baacreditchange*100 
gen ptfsbd_1=ptfsbd*100
gen ptfsfx_1=ptfsfx*100
gen ptfscom_1=ptfscom*100
gen umd_1=umd*100
gen rmw_1=rmw*100
gen cma_1=cma*100
gen bab_1=bab*100
reg excessreturn_s1 mktrf_1 smb_1 tenyrcmtchange_1 baacreditchange_1 ptfsbd_1 ptfsfx_1 ptfscom_1 emfactor,robust
estimates store m6, title((6)) 
  
estout m4 m5 m6 using "d:\Research\networking\sorting(value-weighted).txt", ///
cells(b(star fmt(%9.3f)) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace




/*** robustness tests ***/
/*** fama macbeth ***/
insheet using hf_performance_portfolio.csv,clear
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen excessreturn1=return1-rf*100
gen diver_edu_ratio=1-homo_edu_ratio 
gen diver_work_ratio=1-homo_work_ratio 
asreg return1 diver_edu_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m1, title(return) 

asreg alpha1 diver_edu_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m2, title(alpha) 

asreg return1 diver_work_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m7, title(return) 

asreg alpha1 diver_work_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*,fmb newey(3)
estimates store m8, title(alpha) 

insheet using hf_performance_portfolio.csv,clear
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diveredu_rank100=1-homoedu_rank100
gen diverwork_rank100=1-homowork_rank100
sum diveredu_rank100,d
asreg return1 diveredu_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m3, title(return) 
asreg alpha1 diveredu_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m4, title(alpha) 
asreg return1 diverwork_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m9, title(return) 
asreg alpha1 diverwork_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m10, title(alpha) 

insheet using hf_performance_portfolio_origin.csv,clear
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen lag24return1=lag24return*100
gen lag24alpha1=lag24alpha*100
gen diverorigin_ratio=1-homoorigin_ratio
gen diverorigin_rank100=1-homoorigin_rank100
sum diverorigin_rank100,d
asreg return1 diverorigin_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* , fmb newey(3)
estimates store m5, title(return) 
asreg alpha1 diverorigin_ratio managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* , fmb newey(3)
estimates store m6, title(alpha) 
asreg return1 diverorigin_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* , fmb newey(3)
estimates store m11, title(return) 
asreg alpha1 diverorigin_rank100 managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* , fmb newey(3)
estimates store m12, title(alpha) 
estout m1 m2 m3 m4 m5 m6 m7 m8 m9 m10 m11 m12 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

/*** anomaly robust using equity funds only ***/
 /*** anomaly ***/
  /*** edu ***/
insheet using hf_performance_portfolio_edurank_e1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/68 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank_e1.csv,comma replace 
  
  
 insheet using hf_performance_portfolio_edurank_e2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/155 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank_e2.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank_e3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/161 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank_e3.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank_e4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/124 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank_e4.csv,comma replace 
  
  
insheet using hf_performance_portfolio_edurank_e5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/908 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using edurank_e5.csv,comma replace 
  
  /*** work ***/
insheet using hf_performance_portfolio_workrank_e1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/198 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank_e1.csv,comma replace 
  
  insheet using hf_performance_portfolio_workrank_e2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/245 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank_e2.csv,comma replace 
  
insheet using hf_performance_portfolio_workrank_e3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/281 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank_e3.csv,comma replace 
  
  
insheet using hf_performance_portfolio_workrank_e4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/203 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank_e4.csv,comma replace 
  
  insheet using hf_performance_portfolio_workrank_e5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/577 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using workrank_e5.csv,comma replace 
  
  /*** origin ***/
insheet using hf_performance_portfolio_originrank_e1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/381 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank_e1.csv,comma replace 
  
  
insheet using hf_performance_portfolio_originrank_e2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/414 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank_e2.csv,comma replace 
  
  
insheet using hf_performance_portfolio_originrank_e3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/429 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank_e3.csv,comma replace 
  
insheet using hf_performance_portfolio_originrank_e4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/265 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank_e4.csv,comma replace 
  
insheet using hf_performance_portfolio_originrank_e5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/1848 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i' 
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using originrank_e5.csv,comma replace 
  
  
    
  /*** gender ***/
insheet using hf_performance_portfolio_genderrank_e1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/2083 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank_e1.csv,comma replace 
  
  
insheet using hf_performance_portfolio_genderrank_e2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/312 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank_e2.csv,comma replace 
  
  
insheet using hf_performance_portfolio_genderrank_e3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/304 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank_e3.csv,comma replace 
  
insheet using hf_performance_portfolio_genderrank_e4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/326 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank_e4.csv,comma replace 
  
insheet using hf_performance_portfolio_genderrank_e5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/274 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i' 
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using genderrank_e5.csv,comma replace 
  
  /*** eth ***/
  insheet using hf_performance_portfolio_ethrank_e1.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/1523 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank_e1.csv,comma replace 
  
  
insheet using hf_performance_portfolio_ethrank_e2.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/307 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank_e2.csv,comma replace 
  
  
insheet using hf_performance_portfolio_ethrank_e3.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/407 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank_e3.csv,comma replace 
  
insheet using hf_performance_portfolio_ethrank_e4.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/393 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i'
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank_e4.csv,comma replace 
  
insheet using hf_performance_portfolio_ethrank_e5.csv,clear
keep if totalcount>=12
egen group = group(fund_id)
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen b8=.
gen b9=.
gen b10=.
gen b11=.
gen se1=.
gen se2=.
gen se3=.
gen se4=.
gen se5=.
gen se6=.
gen se7=.
gen se8=.
gen se9=.
gen se10=.
gen se11=.
forval i = 1/692 { 
	reg  return  spread_accrual_adj spread_asset_growth spread_composite_issue spread_distress spread_gp_adj spread_invasset spread_momentum spread_noa spread_oscore spread_roa spread_stock_issue if group == `i'  
	replace b1=_b[spread_accrual_adj] if group == `i'
	replace b2=_b[spread_asset_growth] if group == `i'
	replace b3=_b[spread_composite_issue] if group == `i'
	replace b4=_b[spread_distress] if group == `i'
	replace b5=_b[spread_gp_adj] if group == `i'
	replace b6=_b[spread_invasset] if group == `i'
	replace b7=_b[spread_momentum] if group == `i' 
	replace b8=_b[spread_noa] if group == `i'
	replace b9=_b[spread_oscore] if group == `i'
	replace b10=_b[spread_noa] if group == `i'
	replace b11=_b[spread_stock_issue] if group == `i'
	
	replace se1=_se[spread_accrual_adj] if group == `i'
	replace se2=_se[spread_asset_growth] if group == `i'
	replace se3=_se[spread_composite_issue] if group == `i'
	replace se4=_se[spread_distress] if group == `i'
	replace se5=_se[spread_gp_adj] if group == `i'
	replace se6=_se[spread_invasset] if group == `i'
	replace se7=_se[spread_momentum] if group == `i'
	replace se8=_se[spread_noa] if group == `i'
	replace se9=_se[spread_oscore] if group == `i'
	replace se10=_se[spread_noa] if group == `i'
	replace se11=_se[spread_stock_issue] if group == `i'
} 
  outsheet using ethrank_e5.csv,comma replace 
  
  /*** subperiod sorting ***/
insheet using hf_performance_portfolio10_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homoedu_rank1 == `i' & year<=2004 
	replace con=_b[_cons] if homoedu_rank1 == `i'
	replace b1=_b[mktrf] if homoedu_rank1 == `i'
	replace b2=_b[smb] if homoedu_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homoedu_rank1 == `i'
	replace b4=_b[baacreditchange] if homoedu_rank1 == `i'
	replace b5=_b[ptfsbd] if homoedu_rank1 == `i'
	replace b6=_b[ptfsfx] if homoedu_rank1 == `i'
	replace b7=_b[ptfscom] if homoedu_rank1 == `i'
	replace r2=e(r2_a) if homoedu_rank1 == `i'
	replace se=_se[_cons] if homoedu_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homoedu_rank1
 quietly by homoedu_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

outsheet using portfolio_results.csv,comma replace

estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace
  
insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year<=2004 


insheet using hf_performance_portfolio10_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homoedu_rank1 == `i' & year>2004 
	replace con=_b[_cons] if homoedu_rank1 == `i'
	replace b1=_b[mktrf] if homoedu_rank1 == `i'
	replace b2=_b[smb] if homoedu_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homoedu_rank1 == `i'
	replace b4=_b[baacreditchange] if homoedu_rank1 == `i'
	replace b5=_b[ptfsbd] if homoedu_rank1 == `i'
	replace b6=_b[ptfsfx] if homoedu_rank1 == `i'
	replace b7=_b[ptfscom] if homoedu_rank1 == `i'
	replace r2=e(r2_a) if homoedu_rank1 == `i'
	replace se=_se[_cons] if homoedu_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homoedu_rank1
 quietly by homoedu_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

outsheet using portfolio_results.csv,comma replace

estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace
  
insheet using hf_performance_portfolio_s_edu.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year>2004
  
  
insheet using hf_performance_portfolio10_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homowork_rank1 == `i' & year<=2004
	replace con=_b[_cons] if homowork_rank1 == `i'
	replace b1=_b[mktrf] if homowork_rank1 == `i'
	replace b2=_b[smb] if homowork_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homowork_rank1 == `i'
	replace b4=_b[baacreditchange] if homowork_rank1 == `i'
	replace b5=_b[ptfsbd] if homowork_rank1 == `i'
	replace b6=_b[ptfsfx] if homowork_rank1 == `i'
	replace b7=_b[ptfscom] if homowork_rank1 == `i'
	replace r2=e(r2_a) if homowork_rank1 == `i'
	replace se=_se[_cons] if homowork_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homowork_rank1
 quietly by homowork_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace

  estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year<=2004

insheet using hf_performance_portfolio10_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homowork_rank1 == `i' & year<=2004
	replace con=_b[_cons] if homowork_rank1 == `i'
	replace b1=_b[mktrf] if homowork_rank1 == `i'
	replace b2=_b[smb] if homowork_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homowork_rank1 == `i'
	replace b4=_b[baacreditchange] if homowork_rank1 == `i'
	replace b5=_b[ptfsbd] if homowork_rank1 == `i'
	replace b6=_b[ptfsfx] if homowork_rank1 == `i'
	replace b7=_b[ptfscom] if homowork_rank1 == `i'
	replace r2=e(r2_a) if homowork_rank1 == `i'
	replace se=_se[_cons] if homowork_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homowork_rank1
 quietly by homowork_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace

  estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year<=2004


insheet using hf_performance_portfolio10_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homowork_rank1 == `i' & year>2004
	replace con=_b[_cons] if homowork_rank1 == `i'
	replace b1=_b[mktrf] if homowork_rank1 == `i'
	replace b2=_b[smb] if homowork_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homowork_rank1 == `i'
	replace b4=_b[baacreditchange] if homowork_rank1 == `i'
	replace b5=_b[ptfsbd] if homowork_rank1 == `i'
	replace b6=_b[ptfsfx] if homowork_rank1 == `i'
	replace b7=_b[ptfscom] if homowork_rank1 == `i'
	replace r2=e(r2_a) if homowork_rank1 == `i'
	replace se=_se[_cons] if homowork_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homowork_rank1
 quietly by homowork_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace

  estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_work.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year>2004

  
insheet using hf_performance_portfolio10_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homoorigin_rank1 == `i'  & year<=2004
	replace con=_b[_cons] if homoorigin_rank1 == `i'
	replace b1=_b[mktrf] if homoorigin_rank1 == `i'
	replace b2=_b[smb] if homoorigin_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homoorigin_rank1 == `i'
	replace b4=_b[baacreditchange] if homoorigin_rank1 == `i'
	replace b5=_b[ptfsbd] if homoorigin_rank1 == `i'
	replace b6=_b[ptfsfx] if homoorigin_rank1 == `i'
	replace b7=_b[ptfscom] if homoorigin_rank1 == `i'
	replace r2=e(r2_a) if homoorigin_rank1 == `i'
	replace se=_se[_cons] if homoorigin_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homoorigin_rank1
 quietly by homoorigin_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace
  
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year<=2004
  

   
insheet using hf_performance_portfolio10_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
gen lockupperiod1=lockupperiod/360
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen con=. 
gen b1=.
gen b2=.
gen b3=.
gen b4=.
gen b5=.
gen b6=.
gen b7=.
gen r2=.
gen se=.
forval i = 1/5 { 
	reg  excessreturn  mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if homoorigin_rank1 == `i'  & year>2004
	replace con=_b[_cons] if homoorigin_rank1 == `i'
	replace b1=_b[mktrf] if homoorigin_rank1 == `i'
	replace b2=_b[smb] if homoorigin_rank1 == `i'
	replace b3=_b[tenyrcmtchange] if homoorigin_rank1 == `i'
	replace b4=_b[baacreditchange] if homoorigin_rank1 == `i'
	replace b5=_b[ptfsbd] if homoorigin_rank1 == `i'
	replace b6=_b[ptfsfx] if homoorigin_rank1 == `i'
	replace b7=_b[ptfscom] if homoorigin_rank1 == `i'
	replace r2=e(r2_a) if homoorigin_rank1 == `i'
	replace se=_se[_cons] if homoorigin_rank1 == `i'
	estimates store m`i', title(`i')
} 
 sort homoorigin_rank1
 quietly by homoorigin_rank1: gen dup = cond(_N==1,0,_n)
 drop if dup>=2
 gen stats=con/se
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.2f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

  outsheet using portfolio_results.csv,comma replace
  
estout m1 m2 m3 m4 m5 using "d:\Research\testosterone\baseline_sorting.txt", ///
cells(b(star fmt(%9.6f) ) t(par fmt(%9.2f) )) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace

insheet using hf_performance_portfolio_s_origin.csv,clear
tab strategy
keep if strategy !="Fund of Funds"
reg excessreturn_s mktrf smb tenyrcmtchange baacreditchange ptfsbd ptfsfx ptfscom if year>2004






/*** average of 5 diversity measures ***/
insheet using hf_performance_portfolio_com2.csv,clear
xtset fund_id date
tab year, gen(yeardummy)
keep if strategy !="Fund of Funds"
tab strategy,gen(strategydummy)
gen lockupperiod1=lockupperiod/360
by fund_id: gen logassets = log(size[_n-1])
gen age1=age_hf/12
gen redemption=redemptionfrequency/30
gen return1=return*100
gen alpha1=alpha*100
gen diver_edu_ratio=1-homo_edu_ratio
gen diver_work_ratio=1-homo_work_ratio
gen diver_origin_ratio=1-homoorigin_ratio
gen diver_gender_ratio=1-homo_gender_ratio
gen diver_eth_ratio=1-homoeth_ratio
gen diver_major_ratio=1-homo_major_ratio
gen sat=((sat25+sat75)/2)/10
sum sat,d
sum diver_edu_ratio diver_work_ratio diver_origin_ratio diver_gender_ratio diver_eth_ratio,d
gen diver_avg=(diver_edu_ratio+diver_major_ratio+diver_origin_ratio+diver_gender_ratio+diver_eth_ratio)/5
sum diver_avg,d
gen diver_avg2=diver_avg*diver_avg
outsheet using hf_performance_portfolio_avg.csv,comma replace


ivreg2 return1 diver_avg sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* yeardummy*, cluster(fund_id month)
estimates store m1, title(return) 
ivreg2 alpha1 diver_avg sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* yeardummy*, cluster(fund_id month)
estimates store m2, title(alpha) 

ivreg2 return1 diver_avg diver_avg2 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* yeardummy*, cluster(fund_id month)
estimates store m3, title(return) 
ivreg2 alpha1 diver_avg diver_avg2 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* yeardummy*, cluster(fund_id month)
estimates store m4, title(alpha) 

asreg return1 diver_avg sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* ,fmb newey(3)
estimates store m5, title(return) 
asreg alpha1 diver_avg sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy* ,fmb newey(3)
estimates store m6, title(alpha) 

asreg return1 diver_avg diver_avg2 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m7, title(return) 
asreg alpha1 diver_avg diver_avg2 sat managementfee incentivefee highwatermark lockupperiod1 leveraged age1 redemption logassets  strategydummy*, fmb newey(3)
estimates store m8, title(alpha) 

estout m1 m2 m3 m4 m5 m6 m7 m8 using "d:\Research\testosterone\crosssection(baseline).txt", ///
cells(b(star fmt(%9.3f) drop(_cons )) t(par fmt(%9.2f) drop(_cons))) starlevels(* 0.05 ** 0.01)  ///
stats(r2 N, fmt(%9.3f %9.0g) labels(R-squared))   label collabels(none) varlabels(_cons Constant) replace


